package cn.hanyx.vlog.authservice.service;

import cn.hanyx.vlog.authservice.entity.User;
import cn.hanyx.vlog.authservice.mapper.UserMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * AuthService
 *
 * @author CSS
 * @date 2021/11/10
 */
@Service
@Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
public class AuthService {

    @Resource
    private UserMapper userMapper;

    public User auth(String username, String password) {
        User user = userMapper.findByUAP(username, password);
        if (user == null) {
            throw new SecurityException("用户名或密码错误。");
        }
        return user;
    }
}
